
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Server Push Demo</title>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/4.0.1/socket.io.min.js"></script>
    <script>
        document.addEventListener('DOMContentLoaded', () => {
            const socket = io();
            socket.on('message', (msg) => {
                console.log(msg);
            });
            socket.on('data', (data) => {
                console.log(data);
            });
            // 请求数据按钮点击事件处理函数
            document.getElementById('request-data').addEventListener('click', () => {
                socket.emit('request_data');
            });
        });
    </script>
</head>
<body>
    <h1>Server Push Demo</h1>
    <button id="request-data">Request Data</button>
</body>
</html>

